import sys
import model as model_getil
import year as year_getil
import json
model_list = ['/BMW___BmwMotorradC.html','/BMW___BmwMotorradF.html','/BMW___BmwMotorradG.html','/BMW___BmwMotorradK.html','/BMW___BmwMotorradR.html','/BMW___BmwMotorradS.html']
_main = 'https://www.shopbmwmotorcycles.com/'
product_list = []
for i in model_list:
    model_data = model_getil.get_model(path=i)
    data_obj = json.loads(model_data)
    model_child_array = data_obj['d']
    for model in model_child_array:
        model_name = model["DisplayString"]
        model_link = model["LinkUrl"]
        model_img = _main+model["ImageUrl"]
        # print(model_name)
        # print(model_link)
        # print(model_img)
        year_data = year_getil.get_year(path=model_link)
        year_data = json.loads(year_data)
        year_data = year_data['d']
        for year in year_data:
            year_num = year['DisplayString']
            year_link = year['LinkUrl']
            year_accessory_link = year['AccessoryLinkUrl']
            product_list.append(year_link)
            print(year_link)
#获取图纸数据


